package uno.rocc.controller.system;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import uno.rocc.common.util.Result;
import uno.rocc.framework.core.controller.BaseController;
import uno.rocc.framework.security.service.LoginUserService;
import uno.rocc.system.domain.dto.LoginSysUser;
import uno.rocc.system.domain.dto.RegisterSysUser;

import java.util.Map;

@Slf4j
@RestController
@RequiredArgsConstructor
public class LoginController extends BaseController {
    private final LoginUserService loginUserService;


    @PostMapping("/login")
    @Validated
    public Result login(@RequestBody LoginSysUser loginSysUser) {
        Map<String, Object> info = loginUserService.login(loginSysUser);
        return Result.success(info);
    }

    @PostMapping("/register")
    @Validated
    public Result register(@RequestBody RegisterSysUser registerSysUser) {
        loginUserService.register(registerSysUser);
        return Result.success();
    }


}
